Generate an array using linspace


In [4]:
import numpy as np

# function params = starting value, ending value, number of values
x = np.linspace(0,10,50)

x


Out[4]:
array([ 0.        ,  0.20408163,  0.40816327,  0.6122449 ,  0.81632653,
        1.02040816,  1.2244898 ,  1.42857143,  1.63265306,  1.83673469,
        2.04081633,  2.24489796,  2.44897959,  2.65306122,  2.85714286,
        3.06122449,  3.26530612,  3.46938776,  3.67346939,  3.87755102,
        4.08163265,  4.28571429,  4.48979592,  4.69387755,  4.89795918,
        5.10204082,  5.30612245,  5.51020408,  5.71428571,  5.91836735,
        6.12244898,  6.32653061,  6.53061224,  6.73469388,  6.93877551,
        7.14285714,  7.34693878,  7.55102041,  7.75510204,  7.95918367,
        8.16326531,  8.36734694,  8.57142857,  8.7755102 ,  8.97959184,
        9.18367347,  9.3877551 ,  9.59183673,  9.79591837, 10.        ])

Generate a random matrix of numbers


In [6]:
# function params = matrix dimensions, values per array
x = np.random.rand(1,50)
x


Out[6]:
array([[0.41415351, 0.9181195 , 0.33711261, 0.79498701, 0.31449511,
        0.76775631, 0.36508115, 0.40638581, 0.71940994, 0.39419885,
        0.49020088, 0.16395297, 0.30655131, 0.43315939, 0.44216238,
        0.56052407, 0.76160635, 0.76590509, 0.64009885, 0.65545029,
        0.65533434, 0.76531034, 0.78711497, 0.70419111, 0.77294274,
        0.63507866, 0.28620061, 0.82261895, 0.4922638 , 0.1225532 ,
        0.55453314, 0.25269335, 0.78561532, 0.41418579, 0.71982996,
        0.09290209, 0.03575487, 0.88505877, 0.88564306, 0.99081328,
        0.04781205, 0.1038771 , 0.75724936, 0.14336661, 0.8940402 ,
        0.55437364, 0.2667394 , 0.72743441, 0.20319934, 0.2563412 ]])

In [8]:
x = np.random.rand(5,10)
print(x.shape)
x


(5, 10)
Out[8]:
array([[0.15023359, 0.03604074, 0.31035685, 0.54908344, 0.31715115,
        0.00613767, 0.17881014, 0.09207476, 0.64425837, 0.35861791],
       [0.66518294, 0.48277148, 0.03759089, 0.40508852, 0.7540974 ,
        0.12668918, 0.61411129, 0.59438779, 0.90667171, 0.54833146],
       [0.47069539, 0.87448898, 0.3584527 , 0.67094874, 0.70551568,
        0.14569171, 0.0288633 , 0.1612899 , 0.45529628, 0.78181056],
       [0.03870492, 0.48229101, 0.45100324, 0.89258404, 0.13585657,
        0.00746319, 0.28823971, 0.33380107, 0.29081854, 0.42904784],
       [0.99523294, 0.64336791, 0.90654542, 0.88993883, 0.00349256,
        0.02353537, 0.64955242, 0.41419694, 0.57369116, 0.94224488]])

In [ ]: